home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0020_Trap CTRL-BREAK #2.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  75 lines

  1. {Here is my solution to the problem of trapping Ctrl-Alt-Del. As extra suger,
  2. I'm providing hooks to make this Program TSR. Happy hacking!
  3.  
  4. <<File: trapboot.pas>>
  5.  
  6. {$m 1024,0,0} { Necesarry if you want to make the Program resident. }
  7. {****************************************************************************}
  8. {* NoBoot                                                                   *}
  9. {*                                                                          *}
  10. {* This Program stops rebooting While it is running by trapping             *}
  11. {* Ctrl-Alt-Del.                                                            *}
  12. {*                                                                          *}
  13. {----------------------------------------------------------------------------}
  14.  
  15. Uses
  16.   Dos, Crt;
  17.  
  18. Var
  19.   OldKBVec : Pointer;
  20.  
  21. { Declare all Variables in our interrupt routine global so that no stack }
  22. { allocation of Variables will be done during the interrupt.             }
  23. Var
  24.   Regs : Registers;
  25.   temp : Byte;
  26.   KBflag1: Byte Absolute $40:$17;
  27.  
  28. Procedure MyKB; inTERRUPT;
  29. Const
  30.   EOI = $20;
  31.   KB_DATA = $60;
  32.   KB_CTL = $61;
  33.   inT_CTL = $20;
  34.   DEL_sc = $53;   { Scancode of the del key }
  35.  
  36. begin
  37.   { Check if Alt and Ctrl are pressed }
  38.   if ((KBFlag1 and 4)=4) and ((KBFlag1 and 8)=8) and
  39.     (Port[KB_DATA]= DEL_sc) then begin { get scancode of pressed key }
  40.  
  41.     { The following four lines signals that the key is read and that the }
  42.     { hardware interrupt is over. }
  43.     temp:=Port[Kb_CTL];
  44.     Port[KB_CTL]:= temp or $80;
  45.     Port[KB_CTL]:= temp;
  46.     Port[inT_CTL]:= EOI;
  47.  
  48.     { Don't do ANYTHinG here that requires BIOS. This 'Writeln' is using the }
  49.     { Crt Unit.                                                              }
  50.     Writeln('Ouch! That hurts!');  { Show we are here and alive! }
  51.   end
  52.   else begin
  53.     intr($69, Regs); { Call the old interrupt routine }
  54.   end;
  55. end;
  56.  
  57. Var
  58.   Ch : Char;
  59.  
  60. begin
  61.   GetIntVec($9, OldKBVec);
  62.   SetIntVec($69, OldKBVec);
  63.   SetIntVec($9, @MyKB);
  64.  
  65.   { Keep(0); } { Uncomment and erase the rest of the lines to make this Program}
  66.  
  67.   Repeat
  68.     Writeln('Press escape to Exit. or Ctrl-Alt-Del if you want...');
  69.     ch:= ReadKey;
  70.   Until ch=#27;
  71.  
  72.   { Forgetting the next line will very surely crash your Computer. }
  73.   SetIntVec($9, OldKbVec);
  74. end.
  75.